home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 1514 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.2 KB

  1. Path: news.th-darmstadt.de!news
  2. From: Enno Sandner <enno@intellektik.informatik.th-darmstadt.de>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Why use private class members instead of protected?
  5. Date: Thu, 11 Jan 1996 13:54:12 +0100
  6. Organization: Fachbereich Informatik, TH Darmstadt
  7. Message-ID: <30F50874.15FB7483@intellektik.informatik.th-darmstadt.de>
  8. References: <30F4AB49.6ABB@sierra.net>
  9. NNTP-Posting-Host: kitz.intellektik.informatik.th-darmstadt.de
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0b4 (X11; I; SunOS 4.1.3 sun4m)
  14.  
  15. TGColwell wrote:
  16. > I'm relatively new to c++.  I have one quick question:  If child
  17. > classes can only access protected members of the parent class,
  18. > why make any members of any class private?  Wouldn't it be
  19. > better to make members of the parent class protected so that the
  20. > class is alway "inheritance ready"?
  21.  
  22. No,
  23. it's quite often a better approach to make these data-members private and
  24. provide the suitable accessor functions. In this way you can change the
  25. representation of the data-members without the problem that modifications
  26. will 'propagate' downwards the class-hierachie.
  27.  
  28.     Enno
  29.